package com.func.domain.award.event;

import com.func.types.event.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * <p>
 * SendAwardRecordMessage
 * </p>
 *
 * @author Simon
 * @version 2025.03.15.1.0.0
 * @description
 * @since 2025-03-15
 */

@Component
public class SendAwardMessageEvent extends BaseEvent<SendAwardMessageEvent.SendAwardMessage> {

    @Value("${spring.rabbitmq.topic.send_award}")
    private String topic;
    @Override
    public EventMessage<SendAwardMessage> buildEventMessage(SendAwardMessage data) {
        return EventMessage.<SendAwardMessage>builder()
                .id(RandomStringUtils.randomNumeric(11))
                .timeStamp(new Date())
                .data(data)
                .build();
    }

    @Override
    public String topic() {
        return topic;
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class SendAwardMessage {
        // 用户ID
        private String useId;
        // 奖品ID
        private Integer awardId;
        // 奖品名称
        private String awardTitle;
        // 奖品配置
        private String awardConfig;
        // 订单ID
        private String orderId;
    }
}
